package com.tian.hello.ui.qqfriend;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;

import java.util.ArrayList;

import com.tian.hello.R;

/**
 * Description:QQ好友fragment
 * Author：skyTian
 * Time:2018/2/1
 * CopyRight:com,sky
 */
public class QQFriendsFragment extends Fragment {

    private ViewGroup rootView;

    /**
     * 二级列表
     */
    private ExpandableListView expand_list;

    private ExListAdapter adapter;
    private ArrayList<ExListInfo> exListInfos;


    public static QQFriendsFragment newInstance(Bundle bundle) {
        QQFriendsFragment fragment = new QQFriendsFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = (ViewGroup) inflater.inflate(R.layout.fragment_m, null);
        init();
        return rootView;
    }

    private void init() {
        expand_list = rootView.findViewById(R.id.expand_list);

        exListInfos = new ArrayList<>();
        ArrayList<ExListInfo.ExChildItem> childItems = new ArrayList<>();
        childItems.add(new ExListInfo.ExChildItem("张三"));
        childItems.add(new ExListInfo.ExChildItem("李四"));
        childItems.add(new ExListInfo.ExChildItem("小5"));

        exListInfos.add(new ExListInfo("同学", childItems));
        exListInfos.add(new ExListInfo("老师", childItems));
        exListInfos.add(new ExListInfo("特别关心", childItems));
        adapter = new ExListAdapter(getContext(), exListInfos);

        expand_list.setAdapter(adapter);

    }
}
